package com.wfcm.controller;

import com.wfcm.annotation.IgnoreSign;
import com.wfcm.annotation.IgnoreToken;
import com.wfcm.entity.WfShareEntity;
import com.wfcm.service.WfShareService;
import com.wfcm.utils.R;
import org.apache.http.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RequestMapping("/share")
@Controller
public class ShareController {

    @Autowired
    WfShareService shareService;

    @RequestMapping("/getShare")
    @ResponseBody
    @IgnoreToken
    @IgnoreSign
    public R getShare(HttpServletRequest req){

        String type =  req.getParameter("type");
        String foreignId =  req.getParameter("foreignId");
        String shareType =  req.getParameter("shareType");

        Map map = new HashMap<String,String>();
        map.put("type",type);
        map.put("foreignId",foreignId);
        map.put("shareType",shareType);
        WfShareEntity share = shareService.queryObject(map);

        return R.ok().put("share",share);
    }
}
